package practica6.Problema8Reinas;

import java.util.LinkedList;
import java.util.List;

import engines.BreadthFirstSearchEngine;
import engines.DepthFirstSearchWithVisitedControlEngine;
import engines.IterativeDeepeningSearchEngine;
import framework.IRule;
import framework.SearchProblem;

public class ProblemaReinas<stateReinas> {

    private SearchProblem<StateReinas> problem;
    private DepthFirstSearchWithVisitedControlEngine motor;
    private BreadthFirstSearchEngine<StateReinas> motor2;
    private IterativeDeepeningSearchEngine<StateReinas> motor3;
    private StateReinas tablero;
    private List<IRule<StateReinas>> reglasAv = new LinkedList<IRule<StateReinas>>();

    public ProblemaReinas() {
	tablero = new StateReinas();
	reglasAv.add(new ReglasrReinas());// creo la lista de reglas en este
	// caso es una sola
	problem = new SearchProblem<StateReinas>(tablero, reglasAv);
	motor = new DepthFirstSearchWithVisitedControlEngine(problem);
	motor2 = new BreadthFirstSearchEngine<StateReinas>(problem);
	motor3 = new IterativeDeepeningSearchEngine<StateReinas>(problem);

    }

    public boolean encontroSolucion() {
	return motor.performSearch();
    }

    public boolean encontroSolucion2() {
	return motor2.performSearch();
    }

    public boolean encontroSolucion3() {
	return motor3.performSearch();
    }

    public String getSolution() {
	return motor.getReport();
    }

    public Integer getNodesVisited() {
	return motor.getNodesVisited();
    }

    public String getSolution2() {
	return motor2.getReport();
    }

    // camino
    public LinkedList<StateReinas> camino() {
	LinkedList<StateReinas> lista = (LinkedList<StateReinas>) motor3
		.getPath();
	return lista; 

    }

    public static void main(String[] args) {

	ProblemaReinas<StateReinas> p = new ProblemaReinas<StateReinas>();
	// p.encontroSolucion();
	p.encontroSolucion3();
	System.out.println(p.encontroSolucion3());
	System.out.println(p.camino().toString());
	// System.out.println(p.getSolution());
	// int[][] t = p.getTablero();
	// for (int i = 0; i < 8; i++) {
	// for (int j = 0; j < 8; j++) {
	// System.out.print(t[i][j]);
	// }
	// System.out.println();
	// }
    }

}
